package pe.edu.unap.jurado.Servlets;

import java.io.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

import pe.edu.unap.jurado.BeansDatos.*;
import pe.edu.unap.jurado.Beans.*;

public class CrearTarta extends Servletcito
{
 public CrearTarta()
 {
  fichero = new String("CrearTarta.java");
 }
 
 public void doGet (HttpServletRequest request, HttpServletResponse response)
 throws IOException, ServletException
 {
   response.setContentType("image/png");
   OutputStream salida = response.getOutputStream();
   
   DefaultPieDataset pieDataset = new DefaultPieDataset();
   pieDataset.setValue("Ubuntu", new Integer(75));
   pieDataset.setValue("Xubuntu", new Integer(10));
   pieDataset.setValue("Kubuntu", new Integer(10));
   pieDataset.setValue("Otros", new Integer(5));
   JFreeChart chart = ChartFactory.createPieChart("Sistemas Operativos",pieDataset,true,true,false);
   try
   {
       ChartUtilities.writeChartAsPNG(salida,chart,300,300);
   }
   catch (Exception e)
   {
    System.out.println("Error creando grafico.");
   }
   salida.close();
 }
}
